package grafica;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class ConnectPanel extends JPanel implements ActionListener {
	JLabel hostl = new JLabel("Host");
	JLabel portl = new JLabel("Port");
	JLabel userl = new JLabel("Username");
	JTextField host = new JTextField("localhost",10);	
	JTextField port = new JTextField("4444",10);
	JTextField username = new JTextField("joe",10);
	JButton connetti = new JButton("connetti");
	NetFrame nt;
	
	public ConnectPanel(NetFrame nt) {
		this.nt = nt;
		connetti.addActionListener(this);
		this.add(hostl);
		this.add(host);
		this.add(portl);
		this.add(port);
		this.add(userl);
		this.add(username);
		this.add(connetti);
	}
	public void actionPerformed(ActionEvent e) {
		String h = host.getText();
		String p = port.getText();
		int np = 0;
		if(!p.isEmpty())
			np = Integer.parseInt(p);
		String u = username.getText();
		nt.connetti(h,np,u);
		
	}

}
